home *** CD-ROM | disk | FTP | other *** search
/ Champak Vol F-12 / (Vol F-12) Jun 02 2012.iso / Screensaver / screensaver_installer.exe / ____swmx / scripts / frame_1 / DoAction_19.as < prev    next >
Text File  |  2004-10-21  |  9KB  |  303 lines

  1. _global.ScreenweaverFlashInterface = function()
  2. {
  3. };
  4. Object.registerClass("Screenweaver Interface",ScreenweaverFlashInterface);
  5. ScreenweaverFlashInterface.prototype.init = function()
  6. {
  7.    swInterface.setupConnections();
  8.    swEvents.init();
  9. };
  10. Object.registerClass("Screenweaver Flash Interface",ScreenweaverFlashInterface);
  11. ScreenweaverFlashInterface.prototype._init = function()
  12. {
  13.    this.ID = "Screenweaver Flash Interface build 5.08";
  14.    this.swEvents = new ScreenweaverEvents();
  15.    this.swDebug = new ScreenweaverDebug();
  16.    this.swSystem = new ScreenweaverSystem();
  17.    this.swApplication = new ScreenweaverApplication();
  18.    this.swWindow = new ScreenweaverWindow();
  19.    this.swGlobalMouse = new ScreenweaverGlobalMouse();
  20.    this.swFile = new ScreenweaverFile();
  21.    this.swScript = new ScreenweaverScript();
  22.    _global.swInterface = this;
  23.    _global.swEvents = this.swEvents;
  24.    _global.swDebug = this.swDebug;
  25.    _global.swSystem = this.swSystem;
  26.    _global.swApplication = this.swApplication;
  27.    _global.swWindow = this.swWindow;
  28.    _global.swGlobalMouse = this.swGlobalMouse;
  29.    _global.swFile = this.swFile;
  30.    _global.swScript = this.swScript;
  31.    swDebug.apiTrace("Initializing " + this.ID);
  32.    this.callbackIDCount = 1;
  33.    this.nextCallbackID = -1;
  34.    this.callbackStack = [];
  35.    this.lcr = new LocalConnection();
  36.    this.lcr.allowDomain = function()
  37.    {
  38.       return true;
  39.    };
  40.    this.lcr.Onreceive = function(UniqueID, WindowData, ApplicationData, SystemColors, SystemData, Windows, Files)
  41.    {
  42.       swWindow.Data = WindowData;
  43.       swApplication.Data = ApplicationData;
  44.       swApplication.Files = Files;
  45.       swApplication.Windows = Windows;
  46.       swSystem.Data = SystemData;
  47.       swSystem.Data.monitors = new Array(args.monitorCount);
  48.       swSystem.Data.Colors = SystemColors;
  49.       swInterface.lcr.close();
  50.       delete swInterface.lcr;
  51.       swInterface.LCSWF_receiver_name = "LCreceive_SWF_" + swWindow.Data.HostHandle.toString();
  52.       swInterface.LCSWMX_receiver_name = "LCreceive_SWMX_" + swWindow.Data.HostHandle.toString();
  53.       swApplication.parseCommandLine();
  54.       getURL("FSCommand:sw_callbackProcessed",UniqueID);
  55.       fscommand("sw_windowDatareceived");
  56.    };
  57.    this.lcr.success = false;
  58.    i = 0;
  59.    while(i < 10)
  60.    {
  61.       this.lcr.success = this.lcr.connect("sw_WindowData");
  62.       if(this.lcr.success)
  63.       {
  64.          break;
  65.       }
  66.       i++;
  67.    }
  68.    if(!this.lcr.success)
  69.    {
  70.       swDebug.apiError("Failed setting up listener for receiving window data.");
  71.       return undefined;
  72.    }
  73.    swDebug.apiTrace("Successfully connected to Window Data source.");
  74.    swInterface.getWindowData();
  75. };
  76. ScreenweaverFlashInterface.prototype.getWindowData = function()
  77. {
  78.    fscommand("sw_requestWindowData");
  79. };
  80. ScreenweaverFlashInterface.prototype.setupConnections = function()
  81. {
  82.    swInterface.LCreceive.close();
  83.    swInterface.LCsend.close();
  84.    delete swInterface.LCreceive;
  85.    delete swInterface.LCsend;
  86.    swInterface.LCreceive = new LocalConnection();
  87.    swInterface.allowDomain = function()
  88.    {
  89.       return true;
  90.    };
  91.    swInterface.LCreceive.callMethod_receive = swInterface.genericCallback;
  92.    var tryCount = 0;
  93.    while(!swInterface.LCreceive.connect(swInterface.LCSWF_receiver_name) && tryCount < 3)
  94.    {
  95.       tryCount++;
  96.       swDebug.apiTrace("Failed to initialize tunnel.");
  97.    }
  98.    if(tryCount == 3)
  99.    {
  100.       swDebug.apiTrace("ERROR: Cannot setup communications.\nThis might be a Flash 5 movie?");
  101.    }
  102.    swInterface.LCsend = new LocalConnection();
  103.    swInterface.LCsend.onStatus = function(infoObject)
  104.    {
  105.       if(infoObject.level == "error")
  106.       {
  107.          swDebug.trace("Failed tunneling data.");
  108.       }
  109.    };
  110. };
  111. ScreenweaverFlashInterface.prototype.closeConnections = function()
  112. {
  113.    swInterface.LCreceive.close();
  114.    swInterface.LCsend.close();
  115. };
  116. ScreenweaverFlashInterface.prototype.genericCallback = function(UniqueID, ID)
  117. {
  118.    if(ID == 0)
  119.    {
  120.       if(UniqueID != 0)
  121.       {
  122.          getURL("FSCommand:sw_callbackProcessed",UniqueID);
  123.       }
  124.       return undefined;
  125.    }
  126.    var i = 0;
  127.    while(i < swInterface.callbackStack.length)
  128.    {
  129.       if(swInterface.callbackStack[i].ID == ID)
  130.       {
  131.          var args = [];
  132.          j = 2;
  133.          while(j < arguments.length)
  134.          {
  135.             args.push(arguments[j]);
  136.             j++;
  137.          }
  138.          swInterface.callbackStack[i].Callback.apply(swInterface.callbackStack[i].scope,args);
  139.          if(!swInterface.callbackStack[i].Static)
  140.          {
  141.             swInterface.nextCallbackID = ID;
  142.             swInterface.callbackStack.splice(i,1);
  143.          }
  144.          if(UniqueID != 0)
  145.          {
  146.             getURL("FSCommand:sw_callbackProcessed",UniqueID);
  147.          }
  148.          break;
  149.       }
  150.       i++;
  151.    }
  152. };
  153. ScreenweaverFlashInterface.prototype.addCallback = function(toAdd, ┬ºstatic┬º, scope)
  154. {
  155.    if(typeof toAdd ne "function")
  156.    {
  157.       if(toAdd != undefined && toAdd != 0)
  158.       {
  159.          swDebug.ApiError("Value passed for Callback is not a valid function.");
  160.       }
  161.       return 0;
  162.    }
  163.    this.newEntry = {Callback:toAdd,Scope:(scope != undefined ? scope : this),Static:(!eval("static") ? false : true)};
  164.    if(swInterface.nextCallbackID > 0)
  165.    {
  166.       this.newEntry.ID = swInterface.nextCallbackID;
  167.       swInterface.nextCallbackID = -1;
  168.    }
  169.    else
  170.    {
  171.       this.newEntry.ID = swInterface.callbackIDCount;
  172.       swInterface.callbackIDCount = swInterface.callbackIDCount + 1;
  173.    }
  174.    swInterface.callbackStack.push(this.newEntry);
  175.    return this.newEntry.ID;
  176. };
  177. ScreenweaverFlashInterface.prototype.getCallback = function(ID)
  178. {
  179.    var i = 0;
  180.    while(i < swInterface.callbackStack.length)
  181.    {
  182.       if(swInterface.callbackStack[i].ID == ID)
  183.       {
  184.          return swInterface.callbackStack[i];
  185.       }
  186.       i++;
  187.    }
  188.    return undefined;
  189. };
  190. ScreenweaverFlashInterface.prototype.pushArg = function(argument)
  191. {
  192.    getURL("FSCommand:sw_pushArgument",argument);
  193. };
  194. ScreenweaverFlashInterface.prototype.callDLLMethod = function(source, method, args, callback, scope)
  195. {
  196.    this.apiTrace("callDLLMethod" + swInterface.LCSWMX_receiver_name);
  197.    this.LCsend.onStatus = function(status)
  198.    {
  199.    };
  200.    var CallbackID = swInterface.addCallback(callback,false,scope);
  201.    this.LCsend.send("localhost:" + swInterface.LCSWMX_receiver_name,"callDLLMethod",callbackID,source,method,args);
  202. };
  203. ScreenweaverFlashInterface.prototype.callMethod = function(method, args, callback, ┬ºstatic┬º, scope)
  204. {
  205.    if(callback == undefined)
  206.    {
  207.       callback = 0;
  208.    }
  209.    if(eval("static") == undefined)
  210.    {
  211.       set("static",false);
  212.    }
  213.    var CallbackID = 0;
  214.    if(callback != undefined && callback != 0)
  215.    {
  216.       CallbackID = swInterface.addCallback(callback,eval("static"),scope);
  217.    }
  218.    var retry = 0;
  219.    while(this.LCsend.send("localhost:" + swInterface.LCSWMX_receiver_name,method,CallbackID,args) == false)
  220.    {
  221.       if(retry > 4)
  222.       {
  223.          swDebug.trace("Fatal error: unable to send data to Screenweaver.");
  224.          break;
  225.       }
  226.       swDebug.trace("Error sending data to player. Retrying...");
  227.       swInterface.setupConnections();
  228.       retry += 1;
  229.    }
  230.    return CallbackID;
  231. };
  232. ScreenweaverFlashInterface.prototype.callComMethod = function(method, args, callback, scope, ┬ºstatic┬º)
  233. {
  234.    if(!(args instanceof Object))
  235.    {
  236.       args = {e:"-"};
  237.    }
  238.    if(eval("static") == undefined)
  239.    {
  240.       set("static",false);
  241.    }
  242.    return swInterface.callMethod(method,args,callback,eval("static"),scope);
  243. };
  244. ScreenweaverFlashInterface.prototype.callMethod_stack = function(method, args, callback, ┬ºstatic┬º, scope)
  245. {
  246.    var callback_method = function(method, args, callback, ┬ºstatic┬º, scope)
  247.    {
  248.       swInterface.callMethod(method,args,callback,eval("static"),scope);
  249.       clearInterval(arguments.callee.intId);
  250.    };
  251.    setInterval(callback_method,100,method,args,callback,eval("static"),scope);
  252. };
  253. ScreenweaverFlashInterface.prototype.callMethod_CBID = function(method, args, callbackID)
  254. {
  255.    this.LCsend.send("localhost:" + swInterface.LCSWMX_receiver_name,method,callbackID,args);
  256. };
  257. ScreenweaverFlashInterface.prototype.setEventListener = function(event, callback)
  258. {
  259.    this.Args = new Object();
  260.    this.Args.Event = event;
  261.    this.Args.CallbackID = swInterface.addCallback(callback,true);
  262.    this.OnReturn = function(success)
  263.    {
  264.       if(!success)
  265.       {
  266.          swDebug.apiTrace("Failed setting listner for event: " + event);
  267.       }
  268.    };
  269.    swInterface.callMethod("setEventListener",this.args,this.OnReturn);
  270. };
  271. ScreenweaverFlashInterface.prototype.clearEventListener = function(event)
  272. {
  273.    this.Args = new Object();
  274.    this.Args.Event = event;
  275.    this.OnReturn = function(success, ID)
  276.    {
  277.       if(!success)
  278.       {
  279.          swDebug.apiTrace("Failed to clear event");
  280.       }
  281.    };
  282.    swInterface.callMethod("clearEventListener",this.args,this.OnReturn);
  283. };
  284. ScreenweaverFlashInterface.prototype.createBuffer = function(size)
  285. {
  286.    var result;
  287.    i = 0;
  288.    while(i <= size)
  289.    {
  290.       result += " ";
  291.       i++;
  292.    }
  293.    return result;
  294. };
  295. if(_global.swInterface == undefined)
  296. {
  297.    _global.swInterface = new ScreenweaverFlashInterface();
  298.    swInterface._init();
  299. }
  300. swInterface.onChanged = function()
  301. {
  302. };
  303.